package com.llkj.qingnianguoxue.adapter;

import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chauthai.swipereveallayout.SwipeRevealLayout;
import com.llkj.qingnianguoxue.R;
import com.llkj.qingnianguoxue.bean.MyFriendListBean;
import com.llkj.qingnianguoxue.util.DisplayUtil;
import com.llkj.qingnianguoxue.util.ImageLoadingUtil;

import java.util.List;

/**
 * 我的好友
 */
public class MyFriendsAdapter extends BaseQuickAdapter<MyFriendListBean.FriendBean, BaseViewHolder> {

    public MyFriendsAdapter(int layoutResId, List<MyFriendListBean.FriendBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, MyFriendListBean.FriendBean item) {
        baseViewHolder.setText(R.id.tv_name,item.getUsername());
        ImageView ivHead = baseViewHolder.getView(R.id.iv_head);
        ImageLoadingUtil.loadingImg(ivHead,item.getUserpic(),0);

        SwipeRevealLayout swipeDelGroup = baseViewHolder.getView(R.id.swipeDelGroup);
        TextView tvDelItem = baseViewHolder.getView(R.id.tvDelItem);
//        tvDelItem.getLayoutParams().height = DisplayUtil.dip2px(mContext, 80);
        baseViewHolder.addOnClickListener(R.id.tvDelItem);
                if(isLock){
                    swipeDelGroup.setLockDrag(true);
                }else {
                    swipeDelGroup.close(true);
                    swipeDelGroup.setSwipeListener(new SwipeRevealLayout.SimpleSwipeListener() {
                        @Override
                        public void onClosed(SwipeRevealLayout view) {
                            super.onClosed(view);
                        }

                        @Override
                        public void onOpened(SwipeRevealLayout view) {
                            super.onOpened(view);
                        }
                    });
                }
    }

    private boolean isLock;
    public void setDragLock(boolean isLock){
        this.isLock = isLock;
    }
}
